All Questions
29 questions
0votes
3answers
613views
Adding 10 whitespace characters using sed
I have written a script that replaces a string, but I need to add the 10 whitespace characters back. I can add it back by pressing space 10 times, and that works, but this looks hideous in my script. ...
2votes
3answers
548views
Sed replace the middle string
I have this this String 22<>22 And i have this list test dev too The output should be like 22test22 22dev22 etc.. This is the commands i use for do that cat list | sed 's/$/22/g' | sed 's/^/...
2votes
3answers
1kviews
Replace dynamic word using sed command
I have a requirement where we need to replace a word in a file which can be different everytime I execute the script, the content of the file is class DynamicContentToReplace > Something Here I ...
-1votes
4answers
534views
How to replace a part of the word using sed command
I have a file with just one word in each line. I want to delete some part of the word in each line. How can I delete that part using sed command? Ex: u_fox/u_snake/u_snail/u_plus/u_core/u_vector/...
0votes
1answer
171views
Replacing the word(case senstitive) in a file
I am new to linux, I have one 200 lines in a file. In that file I need to replace the specific word eg: existing word: foo New word : bar I read some blogs...i understood it can be done with sed. ...
1vote
1answer
73views
Replace each letter in a .txt with the letter six positions later
I want to "encrypt" a .txt by replacing each letter with the letter six positions later. What I have right now is: tr [:alpha:] ??? < myfile.txt But I don't know what to put in ??? ... Any help ...
1vote
1answer
2kviews
Bash replace special character '
All the questions and answers i already read are not my solution. So, all i want to do is to replace the special char ' in bash. This works: A="abc" B="${A//[b]/x}" But this does not work: A="a'b" ...
2votes
3answers
483views
How to find the last occurrence of a string in column 1 and replace the corresponding value in column 3?
I have three columns in a file as such: apple1 10109283 20012983 apple1 10983102 10293809 apple1 10293893 2349823049 apple10 109283019 109238901 apple10 ...
0votes
1answer
758views
I am not able to update a variable through sed command
I have assigned two variables but not able to update x=$(cat /scratch/env.properties | grep ConfigPath) y=$(ConfigPath=/scratch/a/b) then sed to replace ConfigPath in env.properties sed 's/$x/$y/' ...
0votes
3answers
2kviews
How to keep the content of a replaced string with sed
I am trying to use sed to replace a line of text that will keep the found text intact and add a colon to the end of it. specifically, in a file there are a bunch of lines in this format ...
7votes
1answer
983views
Is it possible to replace duplicates of a character with one character using tr
I'm trying to take all occurrences of # and if they are consecutive replace them with just one #. e.g. ab ### cde fghi## jklm would become: ab # cde, fghi# jklm My initial goal was to replace all ...
3votes
4answers
2kviews
btrfs replace on RAID1 is super slow with failed disk present
I'm trying to replace a failed disk in a RAID1 btrfs filesystem. I can still mount the partition rw (after about 5 minute delay and lots of I/O kernel errors). I started replace with -r in an ...
0votes
3answers
2kviews
how to find & replace a file path listed in a file
I have a file content as shown below. If a line has ".idt" word, then I need to check if there is a file path preceding it (eg: /bin/dir/test/abcdef.idt). If yes, then remove the file path and keep ...
0votes
2answers
1kviews
sed with variables containing /
i have a text file containing some content like that, some content replace content other content and i have some variables, looking like this: PATH="/path/to/scriptdir" PARAMETERS="para1 ...
0votes
0answers
436views
Why sed s acting differently on RedHat vs Mobaxterm using regexp?
I have a .txt file which includes "junk" characters, emojis. Example: 12/11/2015, 12:07 - 5465464: Super Wakkka👏🏻 12/11/2015, 12:30 - 89415: qwertz svima, nadam se 😊 12/11/2015, 12:34 - 55698742: ...